/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.dengues.model.project.impl;

import org.dengues.model.project.ConnPropertyAttriType;
import org.dengues.model.project.ConnPropertySetType;
import org.dengues.model.project.ProjectPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Conn Property Attri Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.dengues.model.project.impl.ConnPropertyAttriTypeImpl#getValue <em>Value</em>}</li>
 *   <li>{@link org.dengues.model.project.impl.ConnPropertyAttriTypeImpl#getName <em>Name</em>}</li>
 *   <li>{@link org.dengues.model.project.impl.ConnPropertyAttriTypeImpl#getPropertySet <em>Property Set</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ConnPropertyAttriTypeImpl extends EObjectImpl implements ConnPropertyAttriType {
    /**
     * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getValue()
     * @generated
     * @ordered
     */
    protected static final String VALUE_EDEFAULT = null;

    /**
     * The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getValue()
     * @generated
     * @ordered
     */
    protected String value = VALUE_EDEFAULT;

    /**
     * The default value of the '{@link #getName() <em>Name</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getName()
     * @generated
     * @ordered
     */
    protected static final String NAME_EDEFAULT = null;

    /**
     * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getName()
     * @generated
     * @ordered
     */
    protected String name = NAME_EDEFAULT;

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected ConnPropertyAttriTypeImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    protected EClass eStaticClass() {
        return ProjectPackage.Literals.CONN_PROPERTY_ATTRI_TYPE;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String getValue() {
        return value;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setValue(String newValue) {
        String oldValue = value;
        value = newValue;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__VALUE, oldValue, value));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String getName() {
        return name;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setName(String newName) {
        String oldName = name;
        name = newName;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__NAME, oldName, name));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ConnPropertySetType getPropertySet() {
        if (eContainerFeatureID != ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__PROPERTY_SET) return null;
        return (ConnPropertySetType)eContainer();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain basicSetPropertySet(ConnPropertySetType newPropertySet, NotificationChain msgs) {
        msgs = eBasicSetContainer((InternalEObject)newPropertySet, ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__PROPERTY_SET, msgs);
        return msgs;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setPropertySet(ConnPropertySetType newPropertySet) {
        if (newPropertySet != eInternalContainer() || (eContainerFeatureID != ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__PROPERTY_SET && newPropertySet != null)) {
            if (EcoreUtil.isAncestor(this, newPropertySet))
                throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
            NotificationChain msgs = null;
            if (eInternalContainer() != null)
                msgs = eBasicRemoveFromContainer(msgs);
            if (newPropertySet != null)
                msgs = ((InternalEObject)newPropertySet).eInverseAdd(this, ProjectPackage.CONN_PROPERTY_SET_TYPE__ATTRIBUTES, ConnPropertySetType.class, msgs);
            msgs = basicSetPropertySet(newPropertySet, msgs);
            if (msgs != null) msgs.dispatch();
        }
        else if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__PROPERTY_SET, newPropertySet, newPropertySet));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__PROPERTY_SET:
                if (eInternalContainer() != null)
                    msgs = eBasicRemoveFromContainer(msgs);
                return basicSetPropertySet((ConnPropertySetType)otherEnd, msgs);
        }
        return super.eInverseAdd(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__PROPERTY_SET:
                return basicSetPropertySet(null, msgs);
        }
        return super.eInverseRemove(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
        switch (eContainerFeatureID) {
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__PROPERTY_SET:
                return eInternalContainer().eInverseRemove(this, ProjectPackage.CONN_PROPERTY_SET_TYPE__ATTRIBUTES, ConnPropertySetType.class, msgs);
        }
        return super.eBasicRemoveFromContainerFeature(msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public Object eGet(int featureID, boolean resolve, boolean coreType) {
        switch (featureID) {
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__VALUE:
                return getValue();
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__NAME:
                return getName();
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__PROPERTY_SET:
                return getPropertySet();
        }
        return super.eGet(featureID, resolve, coreType);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eSet(int featureID, Object newValue) {
        switch (featureID) {
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__VALUE:
                setValue((String)newValue);
                return;
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__NAME:
                setName((String)newValue);
                return;
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__PROPERTY_SET:
                setPropertySet((ConnPropertySetType)newValue);
                return;
        }
        super.eSet(featureID, newValue);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eUnset(int featureID) {
        switch (featureID) {
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__VALUE:
                setValue(VALUE_EDEFAULT);
                return;
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__NAME:
                setName(NAME_EDEFAULT);
                return;
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__PROPERTY_SET:
                setPropertySet((ConnPropertySetType)null);
                return;
        }
        super.eUnset(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public boolean eIsSet(int featureID) {
        switch (featureID) {
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__VALUE:
                return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__NAME:
                return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
            case ProjectPackage.CONN_PROPERTY_ATTRI_TYPE__PROPERTY_SET:
                return getPropertySet() != null;
        }
        return super.eIsSet(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public String toString() {
        if (eIsProxy()) return super.toString();

        StringBuffer result = new StringBuffer(super.toString());
        result.append(" (value: ");
        result.append(value);
        result.append(", name: ");
        result.append(name);
        result.append(')');
        return result.toString();
    }

} //ConnPropertyAttriTypeImpl
